//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.quickserver.net.GB268753QN;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.quickserver.net.model.Architecture;
import org.quickserver.net.model.GBServerData;
import org.quickserver.net.model.GBServerDataAll;
import org.quickserver.net.server.ClientHandler;
import org.quickserver.util.data.ReadSSBUtil;
import org.quickserver.util.data.ReadUtil;
import org.quickserver.util.data.ReturnUtil;
import org.quickserver.util.data.dataProcessing;

public class sendClient {
    public sendClient() {
    }
    
    /**
     * 水设备 模拟量
     * @param uniqueCode
     * @return
     */
    public Map<String, Object> QNSendSsbMnl(String uniqueCode) {
        return ReadSSBUtil.sendRead("010300000006C5C8", uniqueCode, null, 3);
    }
    
    /**
     * 水设备 数字量
     * @param uniqueCode
     * @return
     */
    public Map<String, Object> QNSendSsbSzl(String uniqueCode) {
    	return ReadSSBUtil.sendRead("01020000000479C9", uniqueCode, null, 2);
    }
    

    public Map<String, Object> QNSend189(String uniqueCode, Date date) {
        if (date == null) {
            date = new Date();
        }

        String[] dates = dataProcessing.getDateTime16(date);
        String datesStr = "";

        for(int i = 0; i < dates.length; ++i) {
            datesStr = datesStr + dates[i];
        }

        return ReadUtil.sendRead("080001BD01" + datesStr, uniqueCode, date, 189);
    }

    public Map<String, Object> QNSend188(String uniqueCode) {
        return ReadUtil.sendRead("030004BC0100", uniqueCode, null, 188);
    }

    public Map<String, Object> QNSend91(String uniqueCode, int min) {
        String minStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(min), 2);
        return ReadUtil.sendRead("0300015B01" + minStr, uniqueCode, null, 91);
    }

    public Map<String, Object> QNSend90(String uniqueCode, Date date) {
        if (date == null) {
            date = new Date();
        }

        String[] dates = dataProcessing.getDateTime16(date);
        String datesStr = "";

        for(int i = 0; i < dates.length; ++i) {
            datesStr = datesStr + dates[i];
        }

        return ReadUtil.sendRead("0800015A01" + datesStr, uniqueCode, date, 90);
    }

    public Map<String, Object> QNSend89(String uniqueCode) {
        return ReadUtil.sendRead("030001590100", uniqueCode, null, 89);
    }

    public Map<String, Object> QNSend88(String uniqueCode) {
        return ReadUtil.sendRead("030004580100", uniqueCode, null, 88);
    }

    public Map<String, Object> QNSend86(String uniqueCode) {
        return ReadUtil.sendRead("030004560100", uniqueCode, null, 86);
    }

    public Map<String, Object> QNSend85(String uniqueCode) {
        return ReadUtil.sendRead("030004550100", uniqueCode, null, 85);
    }

    public Map<String, Object> QNSend84(String uniqueCode, Date date, int total) {
        if (total > 102) {
            return ReturnUtil.Error("查询操作记录数目不能大于102");
        } else {
            if (date == null) {
                date = new Date();
            }

            String[] dates = dataProcessing.getDateTime16(date);
            String datesStr = "";

            for(int i = 0; i < dates.length; ++i) {
                datesStr = datesStr + dates[i];
            }

            String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
            return ReadUtil.sendRead("0900045401" + totalStr + datesStr, uniqueCode, date, 84);
        }
    }

    public Map<String, Object> QNSend81(String uniqueCode) {
        return ReadUtil.sendRead("030004510100", uniqueCode, null, 81);
    }

    public Map<String, Object> QNSend68(String uniqueCode, int sysType, int sysAddress) {
        String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(sysType), 2);
        String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(sysAddress), 2);
        return ReadUtil.sendRead("0400044401" + sysTypeStr + sysAddressStr, uniqueCode, null, 68);
    }

    public Map<String, Object> QNSend67(String uniqueCode, List<Architecture> list) {
        Object obj = GBServerDataAll.handlerMap.get(uniqueCode);
        if (obj == null) {
            return ReturnUtil.Error("此传输装置未连接，操作失败");
        } else {
            ClientHandler handler = (ClientHandler)obj;
            GBServerData ec = (GBServerData)handler.getClientData();
            if (ec == null) {
                return ReturnUtil.Error("此传输装置未连接，操作失败");
            } else if (list.size() == 0) {
                return ReturnUtil.Error("发送指令数据错误");
            } else if (list.size() > 26) {
                return ReturnUtil.Error("发送指令数据对象数目不能大于26");
            } else {
                int total = list.size();
                String number = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total * 6 + 2), 4);
                String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
                String objStr = "";

                for(int i = 0; i < list.size(); ++i) {
                    String str = "";
                    if (!"0101".equals(ec.getDevType()) && !"0103".equals(ec.getDevType())) {
                        if ("0102".equals(ec.getDevType())) {
                            str = String.valueOf(((Architecture)list.get(i)).getTwiceCode());
                        }
                    } else {
                        str = dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getSysAddress()), 3) + dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getLoopNumber()), 3) + dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getComponentNumber()), 3);
                    }

                    String[] strs = dataProcessing.reInfo(str);
                    String qw = strs[3] + strs[2] + strs[1] + strs[0];
                    String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysType()), 2);
                    String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysAddress()), 2);
                    objStr = objStr + sysTypeStr + sysAddressStr + qw;
                }

                String[] numberStrs = dataProcessing.strsToStrs2(number);
                return ReadUtil.sendRead(numberStrs[1] + numberStrs[0] + "0443" + totalStr + objStr, uniqueCode, null, 67);
            }
        }
    }

    public Map<String, Object> QNSend66(String uniqueCode, List<Architecture> list) {
        Object obj = GBServerDataAll.handlerMap.get(uniqueCode);
        if (obj == null) {
            return ReturnUtil.Error("此传输装置未连接，操作失败");
        } else {
            ClientHandler handler = (ClientHandler)obj;
            GBServerData ec = (GBServerData)handler.getClientData();
            if (ec == null) {
                return ReturnUtil.Error("此传输装置未连接，操作失败");
            } else if (list.size() == 0) {
                return ReturnUtil.Error("发送指令数据错误");
            } else if (list.size() > 3) {
                return ReturnUtil.Error("发送指令数据对象数目不能大于3");
            } else {
                int total = list.size();
                String number = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total * 2 + 2), 4);
                String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
                String objStr = "";

                for(int i = 0; i < list.size(); ++i) {
                    String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysType()), 2);
                    String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysAddress()), 2);
                    objStr = objStr + sysTypeStr + sysAddressStr;
                }

                String[] numberStrs = dataProcessing.strsToStrs2(number);
                return ReadUtil.sendRead(numberStrs[1] + numberStrs[0] + "0442" + totalStr + objStr, uniqueCode, null, 66);
            }
        }
    }

    public Map<String, Object> QNSend65(String uniqueCode, int sysType, int sysAddress) {
        String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(sysType), 2);
        String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(sysAddress), 2);
        return ReadUtil.sendRead("0400044101" + sysTypeStr + sysAddressStr, uniqueCode, null, 65);
    }

    public Map<String, Object> QNSend64(String uniqueCode, Date date, int total, int sysType, int sysAddress) {
        if (total > 102) {
            return ReturnUtil.Error("查询操作记录数目不能大于102");
        } else {
            if (date == null) {
                date = new Date();
            }

            String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(sysType), 2);
            String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(sysAddress), 2);
            String[] dates = dataProcessing.getDateTime16(date);
            String datesStr = "";

            for(int i = 0; i < dates.length; ++i) {
                datesStr = datesStr + dates[i];
            }

            String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
            return ReadUtil.sendRead("0B00044001" + sysTypeStr + sysAddressStr + totalStr + datesStr, uniqueCode, date, 64);
        }
    }

    public Map<String, Object> QNSend63(String uniqueCode, List<Architecture> list) {
        Object obj = GBServerDataAll.handlerMap.get(uniqueCode);
        if (obj == null) {
            return ReturnUtil.Error("此传输装置未连接，操作失败");
        } else {
            ClientHandler handler = (ClientHandler)obj;
            GBServerData ec = (GBServerData)handler.getClientData();
            if (ec == null) {
                return ReturnUtil.Error("此传输装置未连接，操作失败");
            } else if (list.size() == 0) {
                return ReturnUtil.Error("发送指令数据错误");
            } else if (list.size() > 63) {
                return ReturnUtil.Error("发送指令数据对象数目不能大于63");
            } else {
                int total = list.size();
                String number = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total * 6 + 2), 4);
                String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
                String objStr = "";

                for(int i = 0; i < list.size(); ++i) {
                    String str = "";
                    if (!"0101".equals(ec.getDevType()) && !"0103".equals(ec.getDevType())) {
                        if ("0102".equals(ec.getDevType())) {
                            str = String.valueOf(((Architecture)list.get(i)).getTwiceCode());
                        }
                    } else {
                        str = dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getSysAddress()), 3) + dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getLoopNumber()), 3) + dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getComponentNumber()), 3);
                    }

                    String[] strs = dataProcessing.reInfo(str);
                    String qw = strs[3] + strs[2] + strs[1] + strs[0];
                    String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysType()), 2);
                    String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysAddress()), 2);
                    objStr = objStr + sysTypeStr + sysAddressStr + qw;
                }

                String[] numberStrs = dataProcessing.strsToStrs2(number);
                return ReadUtil.sendRead(numberStrs[1] + numberStrs[0] + "043F" + totalStr + objStr, uniqueCode, null, 63);
            }
        }
    }

    public Map<String, Object> QNSend62(String uniqueCode, List<Architecture> list) {
        Object obj = GBServerDataAll.handlerMap.get(uniqueCode);
        if (obj == null) {
            return ReturnUtil.Error("此传输装置未连接，操作失败");
        } else {
            ClientHandler handler = (ClientHandler)obj;
            GBServerData ec = (GBServerData)handler.getClientData();
            if (ec == null) {
                return ReturnUtil.Error("此传输装置未连接，操作失败");
            } else if (list.size() == 0) {
                return ReturnUtil.Error("发送指令数据错误");
            } else if (list.size() > 22) {
                return ReturnUtil.Error("发送指令数据对象数目不能大于22");
            } else {
                int total = list.size();
                String number = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total * 6 + 2), 4);
                String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
                String objStr = "";

                for(int i = 0; i < list.size(); ++i) {
                    String str = "";
                    if (!"0101".equals(ec.getDevType()) && !"0103".equals(ec.getDevType())) {
                        if ("0102".equals(ec.getDevType())) {
                            str = String.valueOf(((Architecture)list.get(i)).getTwiceCode());
                        }
                    } else {
                        str = dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getSysAddress()), 3) + dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getLoopNumber()), 3) + dataProcessing.addZeroForNum(String.valueOf(((Architecture)list.get(i)).getComponentNumber()), 3);
                    }

                    String[] strs = dataProcessing.reInfo(str);
                    String qw = strs[3] + strs[2] + strs[1] + strs[0];
                    String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysType()), 2);
                    String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysAddress()), 2);
                    objStr = objStr + sysTypeStr + sysAddressStr + qw;
                }

                String[] numberStrs = dataProcessing.strsToStrs2(number);
                return ReadUtil.sendRead(numberStrs[1] + numberStrs[0] + "043E" + totalStr + objStr, uniqueCode, null, 62);
            }
        }
    }

    public Map<String, Object> QNSend61(String uniqueCode, List<Architecture> list) {
        Object obj = GBServerDataAll.handlerMap.get(uniqueCode);
        if (obj == null) {
            return ReturnUtil.Error("此传输装置未连接，操作失败");
        } else {
            ClientHandler handler = (ClientHandler)obj;
            GBServerData ec = (GBServerData)handler.getClientData();
            if (ec == null) {
                return ReturnUtil.Error("此传输装置未连接，操作失败");
            } else if (list.size() == 0) {
                return ReturnUtil.Error("发送指令数据错误");
            } else if (list.size() > 102) {
                return ReturnUtil.Error("发送指令数据对象数目不能大于102");
            } else {
                int total = list.size();
                String number = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total * 2 + 2), 4);
                String totalStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(total), 2);
                String objStr = "";

                for(int i = 0; i < list.size(); ++i) {
                    String sysTypeStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysType()), 2);
                    String sysAddressStr = dataProcessing.addZeroForNum(dataProcessing.decimalToHex(((Architecture)list.get(i)).getSysAddress()), 2);
                    objStr = objStr + sysTypeStr + sysAddressStr;
                }

                String[] numberStrs = dataProcessing.strsToStrs2(number);
                return ReadUtil.sendRead(numberStrs[1] + numberStrs[0] + "043D" + totalStr + objStr, uniqueCode, null, 61);
            }
        }
    }

    public static void main(String[] args) {
        Map<String, Object> map = null;
        Map<String, Object> map1 = new HashMap();
        map1.put("1", 123);
        System.out.println(map1.size());
        System.out.println("1234".substring(2));
        System.out.println("1234".substring(0, 2));
        System.out.println(dataProcessing.gB18030ByteArrayToUtf8String(dataProcessing.strToBytes("010100000000000000")));
    }
}
